<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ page import="java.sql.*" import="java.io.*"%>
    
<!-- sidebar begins -->	
	<div id="sidebar">
		

	
	<%!
	//declaring public variables
	private String driver;
	private String connection;
	private String user;
	private String password;
%>		
						
<% 
	//to link back to the login.jsp page, uncomment the following:
	//String sessionFlag = ((String) session.getAttribute("login"));
	driver = application.getInitParameter("oracle_driver");
	connection = application.getInitParameter("oracle_db");
	user = application.getInitParameter("oracledb_user");
	password = application.getInitParameter("oracledb_password");
%>
			
			<%
					//connect to database using web.xml stored parameters
					Class.forName(driver);
					Connection connect = DriverManager.getConnection(connection, user, password);
					java.sql.Statement stmnt = connect.createStatement();
					
					ResultSet resSet = stmnt.executeQuery("SELECT pkgname as \"Name\", " +
							"pkgstartdate || ' to ' || pkgenddate as \"Time Frame\", " +
							"pkgdesc as \"Description\", packageid as \"ID\"" +
							"from ictoosd.packages order by pkgstartdate");
					ResultSetMetaData resSetMetaData = resSet.getMetaData();
					/*
					resSet.getString(1) is package name
					resSet.getString(2) is time frame
					resSet.getString(3) is description
					resSet.getString(4) is package id
					*/
					
					//the beginning of the ul, including title, before packages are listed:
					out.println("<h3>Packages</h3>");
					out.println("<ul class=\"sidemenu\">");
					
					while (resSet.next())
					{
						out.print("<li><a href=\"packages.jsp?packid=" + resSet.getString(4) + "\"");
						out.print(" title=\"" + resSet.getString(2) + "\">" + resSet.getString(1) + "<br />");
						out.println("<span>" + resSet.getString(3) + "</span></a></li>");
					}
					//the </ul> at the end of ALL packages
					out.println("</ul>");
					
					//close connection
					connect.close();
			 %>
			<br/>
			<br/>
	
	</div>				
<!-- sidebar ends -->	